﻿
using System;

using MskEdit.Model ;
using MskEdit.Msk.Model ;
using MskEdit.Dxf.Model ;
using MskEdit.Sdk ;


namespace MskEdit {

    public class ProgramComponents {
    
        #region Private data
        
        private static Project anyProject_ ;

        #endregion
        
        #region Public foundation
        
        public ProgramComponents() {
        }

        #endregion
    
        #region Public accessors
                  
        public MskLine tryGetMskLine( MskLineKey anyMskLineKey, MskLine fallbackValue ) {
            
            if ( anyProject_ == null )
                return fallbackValue ;
                
            var anyMskDocument = anyProject_.AnyMskDocument ;
            if ( anyMskDocument == null )
                return fallbackValue ;
                
            var anyMskLine = anyMskDocument.getAnyLineWith( anyMskLineKey, null ) ;
            if( anyMskLine == null )
                return fallbackValue ;
                
            return anyMskLine ;
        }
        
        
        public DxfAttrDataTable tryGetDxfAttrDataTable( string attrdefTag, string attribTag, DxfAttrDataTable fallbackValue ) {
        
            if ( anyProject_ == null )
                return fallbackValue ;
                
            var anyDxfAttrDataTable = anyProject_.tryGetDxfAttrDataTable( attrdefTag, attribTag, null ) ;
            if ( anyDxfAttrDataTable == null )
                return fallbackValue ;
            
            return anyDxfAttrDataTable ;             
        }

        #endregion

        #region Public properties
        
        public Project AnyProject {
            get { return anyProject_ ; }
            set { anyProject_ = value ; }
        }
        
        
        public MskDocument AnyMskDocument {
            get { return ( anyProject_ == null ) ? null : anyProject_.AnyMskDocument ; }
        }
        
        #endregion
    }
}
